<?php
session_start();
header("content-Type: text/html; charset=utf-8");
include_once("conn.php");
include ('class-phpmailer.php');
include ('class-smtp.php');

function actNum()
{	
	$chars_for_actnum=array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v",
	"w","x","y","z","1","2","3","4","5","6","7","8","9","0"
	);

	for($i=0;$i<20;$i++)
	{
		$actnum.=$chars_for_actnum[mt_rand(0,count($chars_for_actnum)-1)];
	}
	
	return $actnum;

}

$sql = "select email from tb_user_info where name='".$_SESSION["current_user"]."'";
$result = mysql_query($sql);
while( $got = mysql_fetch_array($result) )
{
	$email1=$got["email"];

}	

$to=$email1;
$subject="再次检验激活码";
$actnum=actNum();
//$message="您的激活码为：$actnum";
$header="From:929377310@qq.com";
$mail=new PHPMailer();

// 设置PHPMailer使用SMTP服务器发送Email
$mail->IsSMTP();
// 设置邮件的字符编码，若不指定，则为'UTF-8'
$mail->CharSet='GB2312';
// 添加收件人地址，可以多次使用来添加多个收件人
$mail->AddAddress($to);

// 设置邮件正文
$message=$_SESSION['current_user'].",您的激活地址为：http:\\localhost\svn_google\Imin\activate.php?actnum=".$actnum;
$_SESSION["actnum"]=$actnum;
$mail->Body=$message;

// 设置邮件头的From字段。
// 对于网易的SMTP服务，这部分必须和你的实际账号相同，否则会验证出错。
$mail->From='929377310@qq.com';

// 设置发件人名字
$mail->FromName='Wang Jianhua';

// 设置邮件标题
$mail->Subject='Test Mail';

// 设置SMTP服务器。这里使用网易的SMTP服务器。
$mail->Host='smtp.qq.com';

// 设置为“需要验证”
$mail->SMTPAuth=true;

// 设置用户名和密码，即网易邮件的用户名和密码。
$mail->Username='929377310';
$mail->Password='jhvohwdyfcaik';

// 发送邮件。
$mail->Send();
echo "<br>";
echo $_SESSION["current_user"];
echo ":激活码邮件已经发送";
echo "<br>";
//$_SESSION['current_user']=$username1;
echo "<a href='index.php'>返回首页</a>";


//$to=$email1;



?>